<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en">
<head>
<meta charset="utf-8" />
<title>管理员登录 - 大咖讲后台管理系统</title>
<meta name="description" content="User login page" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<!--basic styles-->
<link href="<%=basePath %>bigshot/css/bootstrap.min.css" rel="stylesheet" />
<link href="<%=basePath %>bigshot/css/bootstrap-responsive.min.css" rel="stylesheet" />
<link rel="stylesheet" href="<%=basePath %>bigshot/css/font-awesome.min.css" />
<!--[if IE 7]>
<link rel="stylesheet" href="css/font-awesome-ie7.min.css" />
<![endif]-->
<!--page specific plugin styles-->
<!--fonts-->
<link rel="stylesheet" href="<%=basePath %>bigshot/css/ace-fonts.css" />
<!--ace styles-->
<link rel="stylesheet" href="<%=basePath %>bigshot/css/ace.min.css" />
<link rel="stylesheet" href="<%=basePath %>bigshot/css/ace-responsive.min.css" />
<link rel="stylesheet" href="<%=basePath %>bigshot/css/ace-skins.min.css" />
<!--[if lte IE 8]>
<link rel="stylesheet" href="css/ace-ie.min.css" />
<![endif]-->
<script src="<%=basePath %>bigshot/js/jquery-2.0.3.min.js"></script>
</head>
<body class="login-layout" style="padding-top:8%;">
<div class="main-container ">
	<div class="main-content">
		<div class="row-fluid">
			<div class="span12">
				<div class="login-container">
					<div class="row-fluid">
						<div class="center">
							<h1>
								<img src="images/logo.png" alt="大咖讲">
							</h1>
						</div>
					</div>

					<div class="space-6"></div>
						<div class="row-fluid">
							<div class="position-relative">
								<div id="login-box" class="login-box visible widget-box no-border">
									<div class="widget-body">
										<div class="widget-main">
											<h4 class="header lighter bigger">
												<i class="icon-coffee" style="color:#00b38a;"></i>
												<font color="#00b38a;">请输入您的登录账户信息</font>
											</h4>

											<div class="space-6"></div>
												<form method="post" ><!-- action="/admin.php?m=Admin&c=Login&a=login" onsubmit="return CheckLogin(this)" -->
													<fieldset>
														<label>
															<span class="block input-icon input-icon-right">
																<input type="text" class="span12" name="username" required="required" placeholder="用户名" />
																<i class="icon-user"></i>
															</span>
														</label>

														<label>
															<span class="block input-icon input-icon-right">
																<input type="password" class="span12" name="password" required="required" placeholder="密码" />
																<i class="icon-lock"></i>
															</span>
														</label>

														<label>
															<span class="block input-icon input-icon-right">
																<input type="text" class="span12" name="verify" required="required" placeholder="验证码"/>
															<input type="text" onClick="createCode()" readonly="readonly" id="checkCode" class="unchanged" title="看不清？点击切换！" alt="看不清？点击切换！" style="width: 80px;cursor:pointer"  />
																<i class="icon-tag"></i>
															</span>
														</label>
													
														<span class="block input-icon input-icon-right">
															<img class="img_change" src="img/admin.php" style="cursor:pointer;" title="看不清？点击切换！" alt="看不清？点击切换！" onclick="this.src='/admin.php/Login/verify?rnd='+Math.random();">
															<button type="submit" class="width-35 pull-right btn btn-small btn-primary" onclick="return CheckLogin(this.form)">
																<i class="icon-key"></i>
																	登陆
															</button>
														</span>
														<a href="<%=basePath %>redirect/retrieve_password.do">忘记密码？</a>
													</fieldset>
												</form>
											</div><!--/widget-main-->
										</div><!--/widget-body-->
									</div><!--/login-box-->
								</div><!--/position-relative-->
							</div>
					</div>
			</div><!--/.span-->
		</div><!--/.row-fluid-->
	</div>
</div><!--/.main-container-->

<!--basic scripts-->

<!--[if !IE]>-->
<script type="text/javascript">
	window.jQuery || document.write("<script src='js/jquery-2.0.3.min.js'>"+"<"+"/script>");
</script>
<!--<![endif]-->
<!--[if IE]>
<script type="text/javascript">
 window.jQuery || document.write("<script src='js/jquery-1.10.2.min.js'>"+"<"+"/script>");
</script>
<![endif]-->
<script type="text/javascript">
	function CheckLogin(form){
		var Vusername = form.username.value;
		var Vpassword = form.password.value;
		var Vverify = form.verify.value;
		if(Vusername==""){
			alert("登录用户名不能为空！");
			form.username.focus();
			return false;
		}else if(Vpassword==""){
			alert("登录密码不能为空！");
			form.password.focus();
			return false;		
		}else if(Vverify==""){
			alert("验证码不能为空！");
			form.verify.focus();
			return false;
		}else{
			var inputCode = Vverify;
			if(inputCode.toUpperCase() != code ){
			alert("验证码输入错误！");
				createCode();//刷新验证码 
			}else{
				$.ajax({
					type:'post',
					url:'<%=basePath %>AdministratorController/loginCheck.do?username='
							+Vusername+'&password='+Vpassword,
					async : false,
					success:function(data){
						if(data==1)
							window.location.href="<%=basePath %>redirect/index.do";
						else if(data==0)
							alert("用户名或密码输入错误！请重新输入！");
					}
				});
				//form.submit();
			}  
		}
	}

	var code ; //在全局 定义验证码 
	function createCode(){
		code = "";
		var codeLength = 6;//验证码的长度  
		var checkCode = document.getElementById("checkCode");
		var selectChar = new Array(0,1,2,3,4,5,6,7,8,9,'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z');//所有候选组成验证码的字符，当然也可以用中文的 
		for(var i=0;i<codeLength;i++){
			var charIndex = Math.floor(Math.random()*36);
			code +=selectChar[charIndex];
		}
		if(checkCode){
			checkCode.className="code";
			checkCode.value = code;
			checkCode.blur();
		}
	}
</script>
</body>
</html>